﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

namespace LitTools
{
    /// <summary>
    /// 名字过滤器
    /// 名字在列表中的物体可通过
    /// </summary>
    public class NameFilter : FilterBase
    {
        [Header("名字列表")]
        public List<string> nameList;

        public override List<RaycastResult> FiltResults(List<RaycastResult> result)
        {
            if(nameList==null
                || nameList.Count == 0)
            {
                Debug.LogError("nameList is null");
                return null;
            }
            if (result == null) 
            {
                Debug.Log("result is null");
                return result; 
            }
            for (int i = 0; i < result.Count; i++)
            {
                if (!nameList.Contains(result[i].gameObject.name))
                {
                    result.RemoveAt(i);
                    i--;
                }
            }
            return result;
        }
    }
}